package com.example.chapter3boot_mybatis.controller;

import com.example.chapter3boot_mybatis.Service.EmployeeService;
import com.example.chapter3boot_mybatis.entity.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/emp")
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;

    @GetMapping("/{employ}")
    public String getByEmp(@PathVariable Integer empno,
                           Model model){
        Employee employee = employeeService.getEmp(empno);
        model.addAttribute("employee",employee);
        return "emp";
    }
}
